from mybatis import Mybatis, ConnectionFactory
import sqlite3


config = {
    'database': {
        'driver': 'sqlite',
        'host': 'example.db',
        'username': '',
        'password': '',
        'database': 'example.db'
    }
}
conn = ConnectionFactory.get_connection('sqlite3', "../databases/example.db")
mb = Mybatis(conn, "mapper.xml")

# 定义 SQL 映射
@mb.SelectOne("SELECT * FROM users WHERE id=#{id}")
def get_user_by_id(id: int):
    pass

@mb.Insert("INSERT INTO users (name, age) VALUES (#{name}, #{age})", primary_key="id")
def insert_user(name: str, age: int):
    pass

@mb.Update("UPDATE users SET name=#{name}, age=#{age} WHERE id=#{id}")
def update_user(id: int, name: str, age: int):
    pass

@mb.Delete("DELETE FROM users WHERE id=#{id}")
def delete_user(id: int):
    pass

# 插入数据
insert_user(name='Alice', age=30)
print("Inserted user with ID:")